package model;

public class PredictionEnergyProfile {

	private String usageType;
	private double[] industry = new double[EnergyProfile.INDUSTRY.length];
	private double daytype; //weekday=0, weekend=1
	private double[] month = new double[12];
	private double[] hour = new double[24];
	private double intercept;
	
	public ProbabilityUsagetype getProbabilityUsagetype(SimpleEnergyProfile profile) {
		ProbabilityUsagetype probusage = new ProbabilityUsagetype();
		probusage.setUsageType(this.getUsageType());
		probusage.setZ(this.getZ(profile));
		probusage.setProbability(1.0/(1.0+Math.pow(Math.E, 0.0-probusage.getZ())));
		return probusage;
		
	}
/*	not efficient
 * public double getProbability(SimpleEnergyProfile profile) {
		return 1.0/(1.0+Math.pow(Math.E, 0.0-getZ(profile)));
	}*/
	
	public double getZ(SimpleEnergyProfile profile){		
		double zvalue = intercept;
		if (this.industry!=null) {
		if (EnergyProfile.INDUSTRY[EnergyProfile.COMMERCIAL].equals(profile.getIndustry()))
			zvalue += industry[EnergyProfile.COMMERCIAL];
		else if (EnergyProfile.INDUSTRY[EnergyProfile.INDUSTRIAL].equals(profile.getIndustry()))
			zvalue += industry[EnergyProfile.INDUSTRIAL];
		else if (EnergyProfile.INDUSTRY[EnergyProfile.RESIDENTIAL].equals(profile.getIndustry()))
			zvalue += industry[EnergyProfile.RESIDENTIAL];
		}
		
		if (this.month!=null)
			zvalue += month[Integer.valueOf(profile.getMonth())-1];
		
		if (EnergyProfile.DAY_TYPE[EnergyProfile.WEEKEND].equals(profile.getDay()))
			zvalue += daytype;
		
		for (int i=0;i<24;i++) {
			zvalue += hour[i]*profile.getEnergyProfile()[i];
		}		
		return zvalue;
	}
	
/*	private double getZAllMonths(SimpleEnergyProfile profile){
		return getZNoMonths(profile)+ month[Integer.valueOf(profile.getMonth())-1];
	}
	
	private double getZNoMonths(SimpleEnergyProfile profile){
		double zvalue = intercept;
		if (EnergyProfile.INDUSTRY[EnergyProfile.COMMERCIAL].equals(profile.getIndustry()))
			zvalue += industry[EnergyProfile.COMMERCIAL];
		else if (EnergyProfile.INDUSTRY[EnergyProfile.INDUSTRIAL].equals(profile.getIndustry()))
			zvalue += industry[EnergyProfile.INDUSTRIAL];
		else if (EnergyProfile.INDUSTRY[EnergyProfile.RESIDENTIAL].equals(profile.getIndustry()))
			zvalue += industry[EnergyProfile.RESIDENTIAL];
		
		if (EnergyProfile.DAY_TYPE[EnergyProfile.WEEKEND].equals(profile.getDay()))
			zvalue += daytype;
		
		for (int i=0;i<24;i++) {
			zvalue += hour[i]*profile.getEnergyProfile()[i];
		}		
		return zvalue;
	}*/
	
	public String getUsageType() {
		return usageType;
	}

	public void setUsageType(String usageType) {
		this.usageType = usageType;
	}

	public double[] getIndustry() {
		return industry;
	}

	public void setIndustry(double[] industry) {
		this.industry = industry;
	}

	public double getDaytype() {
		return daytype;
	}

	public void setDaytype(double daytype) {
		this.daytype = daytype;
	}

	public double[] getMonth() {
		return month;
	}

	public void setMonth(double[] month) {
		this.month = month;
	}

	public double[] getHour() {
		return hour;
	}

	public void setHour(double[] hour) {
		this.hour = hour;
	}

	public double getIntercept() {
		return intercept;
	}

	public void setIntercept(double intercept) {
		this.intercept = intercept;
	}
}
